home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / FPGAWKII.ZIP / COMPLEME.PDS < prev    next >
Text File  |  1994-10-05  |  3KB  |  65 lines

  1. ;---------------------------------------------------------
  2. ; This is a PLDASM file for a 7-bit 2's-complementer that
  3. ; uses the previously-defined 8-bit adder module.
  4. ;---------------------------------------------------------
  5. TITLE   complementer
  6.  
  7. CHIP    compleme    NFX780_84
  8.  
  9. ;---------------------------------------------------------
  10. ; To form the 2's-complement of a binary number, you have
  11. ; to invert all the bits and add 1.  So, use EQUATIONS
  12. ; to invert the input bits, and then use the 8-bit adder
  13. ; module to add a 1 to the inverted bits.
  14. ; This will form the 2's-complement.
  15. ;---------------------------------------------------------
  16. PIN  [47:51]  a[0:4]  ;* the number to be 2's-complemented
  17. PIN  [77:78]  a[6:5]
  18. PIN  [34:37]  cp[0:3] ;* the 2's-complement of a[0:6]
  19. PIN  [39:41]  cp[4:6]
  20. PIN           cout    ;* dump the carry output here
  21. PIN           inv[0:6]  ;* the inversion of a[0:6] will be
  22.                         ;* stored on these nodes
  23.  
  24. ;---------------------------------------------------------
  25. ; Now call the adder module.  Note that the compiler must
  26. ; be told what FILE the adder module description is stored
  27. ; in.  Note that no carry input goes to the adder, nor is
  28. ; the carry output used. Instead, the carry input is tied
  29. ; to ground and the carry output is left floating on a
  30. ; NODE variable.  Note also that the a input to the adder
  31. ; is tied to the inversion of the a input.  Note also that
  32. ; the least-significant bit of the b adder input is tied
  33. ; to VCC (+5V or a logic 1) while the upper 7 bits of the
  34. ; b input are grounded (logic 0).  With this arrangement,
  35. ; a 1 will be added to the inversion of the a input, thus
  36. ; giving the desired 2's-complement.
  37. ;---------------------------------------------------------
  38. MODULE add8 FILE addmodul ( a[0:6]=inv[0:6], a7=GND,
  39.                       b0=VCC, b1=GND, b2=GND, b3=GND,
  40.                       b4=GND, b5=GND, b6=GND, b7=GND,
  41.                       cin=GND, 
  42.                       sum[0:7]=cp[0:7], cout=cout )
  43.  
  44.  
  45. ;---------------------------------------------------------
  46. ; Here are the logic equations for inverting the a input
  47. ;---------------------------------------------------------
  48. EQUATIONS
  49.     inv[0:6] = /a[0:6]  ;* inverts all 7 inputs with a
  50.                         ;* single statement
  51.  
  52.  
  53. ;---------------------------------------------------------
  54. ; Here is the simulation of the 2's-complementer.
  55. ;---------------------------------------------------------
  56. SIMULATION
  57.  
  58.     VECTOR in_a := [a6, a5, a4, a3, a2, a1, a0]
  59.     VECTOR comp := [cp6,cp5,cp4,cp3,cp2,cp1,cp0]
  60.     TRACE_ON in_a comp
  61.     FOR i:=0 TO 127 DO
  62.         BEGIN
  63.         SETF in_a := i
  64.         END
  65.